const { ccclass, property } = cc._decorator;

@ccclass
export default class Helloworld extends cc.Component {

    @property(cc.Sprite)
    icon: cc.Sprite = null;

    @property(cc.Label)
    outlineWidth: cc.Label = null;
    @property(cc.Slider)
    slider: cc.Slider = null;

    start() {
        this.slider.progress = 0.5;
        this._update(0.5)
    }

    silderEvent(obj: cc.Slider) {
        let ratio = obj.progress;
        this._update(ratio);

    }

    _update(ratio: number) {
        let outline = (10*ratio).toFixed(2);
        this.outlineWidth.string = `${outline}`
        let material = this.icon.getMaterial(0);
        let width = this.icon.spriteFrame.getOriginalSize().width;
        let height = this.icon.spriteFrame.getOriginalSize().height;
        // material.define("USE_ROUND", true);
        material.setProperty("textureSize", new cc.Vec2(width, height));
        material.setProperty("outlineWidth", outline);
    }
}
